package com.neuedu.web;

import com.neuedu.pojo.AdminTable;
import com.neuedu.pojo.Familymember;
import com.neuedu.pojo.Result;
import com.neuedu.service.AdminTableService;
import com.neuedu.service.FamilymemberService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/familymember")
@Tag(name="家庭成员管理")
public class FamilyMemberController {
    @Resource
    private FamilymemberService familymemberService;

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("/id")
    public Result<Familymember> getFamilymemberById(Integer id) {return this.familymemberService.getFamilymemberById(id);}
    /**
     * 分页和条件查询
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/getFamilymember")
    public Result<List<Familymember>> getFamilymember(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize){
        return this.familymemberService.getFamilymember(currentPage,pageSize);
    }
    /**
     * 添加
     */
    @PostMapping("/addFamilymember")
    public Result<Void> addFamilymember(@RequestBody Familymember familymember) {
        return this.familymemberService.addFamilymember(familymember);
    }

    /**
     * 修改
     */
    @PutMapping("/updateFamilymember")
    public Result<Void> updateFamilymember(@RequestBody Familymember familymember) {
        return this.familymemberService.updateFamilymember(familymember);
    }

    /**
     * 删除
     */
    @DeleteMapping("/deleteFamilymember")
    public Result<Void> deleteFamilymember(Integer id) {
        return this.familymemberService.deleteFamilymember(id);
    }
}
